﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.SessionState;
using VideoNetApplication.Common.Service;

namespace VideoNetApplication.Handler
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class UserHandler : IHttpHandler, IReadOnlySessionState
    {

        public void ProcessRequest(HttpContext context)
        {
            string opType = context.Request.Form["OpType"];
            var controler = new StudentService(context);
        
            string rtnMessage = string.Empty;
            switch (opType)
            {
                //学员注册的时候验证用户名
                case "VerifyUserName":
                    rtnMessage = controler.CheckUserExit();
                    break;
                //学员注册
                case "Regist":
                    rtnMessage = controler.RegistUser();
                    break;
                //密码找回验证用户名
                case "FindPwd":
                    rtnMessage = controler.CheckUserExit();
                    break;
                 //发送新密码
                case "SendUserPwd":
                    rtnMessage = controler.FindUserPwd();
                    break;
                case "UserLogin":
                    rtnMessage = controler.UserLogin();
                    break;
                case "LoginOut":
                    rtnMessage = controler.LoginOut();
                    break;
                case "SubmitComment":
                  rtnMessage=  controler.SubmitComment();
                    break;
                case "ChkPwd":
                    rtnMessage = controler.CheckUserPass();
                    break;
                case "GetComment":
                    rtnMessage = controler.GetComment();
                    break;
                case "Modify":
                    rtnMessage = controler.ModifyUser();
                    break;
               
                    


            };

            context.Response.ContentType = "text/plain";
            context.Response.Write(rtnMessage);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
